<template>
  <div class="main">
    <div class="top">消息</div>
    <div class="list">
      <div>
        <div class="fabulous iconfont">&#xe635;</div>
        <span>赞和收藏</span>
      </div>
      <div>
        <div class="follow iconfont">&#xe60d;</div>
        <span>新增关注</span>
      </div>
      <div>
        <div class="comment iconfont">&#xe67c;</div>
        <span>评论和@</span>
      </div>
    </div>
    <div class="newsList">
      <div class="news" v-for="(el,index) in chatList" :key="index"
      @click="goToChat(el.userName)">
        <img :src="el.imgUrl">
        <div class="right">
          <div class="name">{{ el.userName }}</div>
          <div class="content">{{ el?.contentList[el.contentList.length-1].content }}</div>
        </div>
      </div>
      <!-- <div class="news">
        <img src="../assets/img/users/head/panlinli.jpg" alt="">
        <div class="right">
          <div class="name">潘林礼-</div>
          <div class="content">你好呀！</div>
        </div>
      </div> -->
    </div>
  </div>
</template>
<script>
import { mapMutations, mapState } from 'vuex';
export default {
  data() {
    return {};
  },
  methods: {
    ...mapMutations(['getCurrentChat']),
    goToChat(user){
      this.$store.commit('getCurrentChat',user);
      if(this.mine.num!=='15875192517'){
        this.$router.push('/chata')
      }else{
      this.$router.push('/chatb')
      }
    }
  },
  computed:{
    ...mapState(['chatList','mine'])
  }
};
</script>

<style scoped lang='scss'>
.main {
  padding-top: 60px;
  padding-bottom: 80px;
  .top {
    width: 100%;
    height: 50px;
    font-size: 26px;
    line-height: 50px;
    text-align: center;
  }
  .list {
    width: 100%;
    height: 100px;
    display: flex;
    justify-content: space-around;
    box-shadow: 2px 2px 4px #ccc;
    margin-bottom: 5px;
    > div {
      width: 60px;
      height: 100%;
      // background: red;
      display: flex;
      flex-direction: column;
      padding: 10px 0;
      box-sizing: border-box;
      >div{
        width: 100%;
        height: 60px;
        border-radius: 15px;
        font-size: 35px;
        line-height: 60px;
        text-align: center;
      }
      .fabulous {
        background: rgba(255, 0, 0, 0.2);
        color: #DC7A75;
      }
      .follow {
        background: rgba(0, 255, 255, 0.2);
        color: #6290EB;
      }
      .comment{
        background: rgba(0, 255, 0, 0.2);
        color: #78C8A0;
      }
      span {
        font-size: 14px;
      }
    }
  }
  .newsList{
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    min-height: 510px;
    background: #FAFAFA;
    .news{
      width: 100%;
      height: 80px;
      background: #fff;
      margin: 5px 0;
      display: flex;
      padding: 10px 5px;
      box-sizing: border-box;
      border-radius: 10px;
      box-shadow: 2px 2px 4px #ccc;
      img{
        width: 60px;
        height: 60px;
        display: block;
        margin-right: 10px;
        border-radius: 50%;
      }
      .right{
        display: flex;
        flex-direction: column;
        flex: 1;
        >div{
          width: 100%;
          height: 30px;
          line-height: 30px;
        }
        .name{
          font-size: 16px;
        }
        .content{
          font-size: 14px;
          color: rgb(145, 145, 145);
        }
      }
    }
  }
}
</style>